package com.hushow.demo.process;

import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
@StepScope
public class MyItemReader implements ItemReader {

    @Value("#{jobParameters[taskId]}")
    private String taskId;

    @Override
    public List<MyPerson> read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {

        List<MyPerson> peopleList = new ArrayList<>();
        peopleList.add(new MyPerson().setFirstName("a").setLastName("1"));
        peopleList.add(new MyPerson().setFirstName("b").setLastName("1"));
        peopleList.add(new MyPerson().setFirstName("c").setLastName("1"));

        return peopleList;
    }
}
